<template>
  <view class="my-rights-container">
    <!-- 顶部功能区 -->
    <view class="top-card">
      <view class="top-title">我的权益</view>
      <view class="top-section">
        <view class="action-item" v-for="(item, index) in actions" :key="index">
          <text class="action-count">{{ item.count }}</text>
          <text class="action-name">{{ item.name }}</text>
        </view>
      </view>
    </view>

    <view class="info">
      <!-- 切换选项卡 -->
      <view class="tabs">
        <view
          class="tab"
          :class="{ active: currentTab === 'package' }"
          @click="switchTab('package')"
        >
          套餐列表
        </view>
        <view
          class="tab"
          :class="{ active: currentTab === 'history' }"
          @click="switchTab('history')"
        >
          购买记录
        </view>
      </view>

      <!-- 套餐列表 -->
      <view v-if="currentTab === 'package'" class="package-list">
        <!-- 套餐列表顶部 -->
        <view class="package-top">
          <text class="package-title">套餐列表</text>
          <text class="package-amount">￥0.00</text>
        </view>

        <!-- 套餐项 -->
        <view class="package-row">
          <view class="package-item" v-for="(item, index) in packages" :key="index">
            <text class="package-count">{{ item.count }}</text>
            <text class="package-name">{{ item.name }}</text>
          </view>
        </view>
      </view>

      <!-- 购买记录 -->
      <view v-if="currentTab === 'history'" class="purchase-history">
        <view class="history-item" v-for="(item, index) in history" :key="index">
          <text class="history-date">{{ item.date }}</text>
          <text class="history-detail">{{ item.detail }}</text>
        </view>
      </view>
    </view>

    <!-- 没有更多 -->
    <view class="no-more">
      <text>~没有更多~</text>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      // 功能区数据
      actions: [
        { name: "我的权益", count: 0 },
        { name: "查看简历", count: 0 },
        { name: "邀请面试", count: 0 },
        { name: "刷新职位", count: 0 },
      ],
      // 当前选中的选项卡
      currentTab: "package",
      // 套餐列表数据
      packages: [
        { name: "发布职位", count: 60 },
        { name: "查看简历", count: 60 },
        { name: "邀请面试", count: 60 },
        { name: "刷新职位", count: 60 },
      ],
      // 购买记录数据
      history: [
        { date: "2023-10-01", detail: "购买发布职位套餐 x1" },
        { date: "2023-09-25", detail: "购买查看简历套餐 x1" },
      ],
    };
  },
  methods: {
    // 切换选项卡
    switchTab(tab) {
      this.currentTab = tab;
    },
  },
};
</script>

<style scoped>
.my-rights-container {
  height: 844px;
  background: #fdfdfd;
}

/* 顶部功能区 */
.top-card {
  width: 351px;
  height: 119px;
  border-radius: 5px 5px 0px 0px;
  background: #e5e5ff;
  padding: 20px;
  margin: 0 20px;
}

.top-title {
  color: #2d2d2d;
  font-size: 15px;
  margin-bottom: 10px;
}

.top-section {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
}

.action-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.action-count {
  font-size: 24px;
  color: #2f318b;
}

.action-name {
  font-size: 14px;
  color: #202020;
}

.info {
  background-color: #fff;
}

/* 选项卡 */
.tabs {
  display: flex;
  justify-content: space-around;
  margin: 10px 20px;
  border-bottom: 1px solid #ebebeb;
}

.tab {
  color: #121212;
  font-size: 13px;
  padding: 10px 20px;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

.tab.active {
  color: #151515;
  font-size: 15px;
  border-bottom-color: #2f318b;
}

/* 套餐列表 */
.package-list {
  margin: 0 10px;
  padding: 20px;
  background-color: #fff;
}

/* 套餐列表顶部 */
.package-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.package-title {
  font-size: 16px;
  color: #333;
}

.package-amount {
  font-size: 16px;
  color: #ED3232;
}

/* 套餐项 */
.package-row {
  display: flex;
  justify-content: space-between;
}

.package-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
  border-radius: 5px;
  margin-bottom: 10px;
}

.package-count {
  font-size: 24px;
  color: #2f318b;
  margin-bottom: 5px;
}

.package-name {
  font-size: 14px;
  color: #333;
}

/* 购买记录 */
.purchase-history {
  margin-bottom: 20px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  padding: 10px;
  background-color: #fff;
  border-radius: 5px;
  margin-bottom: 10px;
}

.history-date {
  font-size: 14px;
  color: #666;
}

.history-detail {
  font-size: 14px;
  color: #333;
}

/* 没有更多 */
.no-more {
  text-align: center;
  font-size: 14px;
  color: #999;
  margin-top: 20px;
}
</style>